
export default {
    data() {
        return {
            src: '',
            share: {
                foo: '',
                path: '',
                imageUrl: ''
            }
        }

    },
    onLoad(option) {
        /**
         * share:是否可分享 1:禁止分享 打开分享不需要传参
         * src:页面地址
         */
        let that = this;
        if (option.share==1) {
            uni.hideShareMenu({
                success: (res) => { },
            })
        }
       
        if (option.src) {
            this.src = decodeURIComponent(option.src)
            console.log(this.src)
        }
        else {
            uni.showToast({
                title: "链接错误！",
                icon: "none",
                duration: 100000000000
            });
        }
    },
    methods: {
        showShare() {
            let timer = setInterval(() => {
                if (this.share.foo) {
                    uni.showShareMenu({ withShareTicket: true, })
                    clearInterval(timer)
                }
            }, 1000)
        },
        /**
         * 
         * @param {*} res接收h5传参
         * h5传参代码 wx.miniProgram.postMessage({ data: { foo: that.input1,path:'pages/index/index' } })
         */
        getMessage(res) {
            this.share = res.mp.detail.data[0];
        },
    },
    onShareAppMessage: function () {
        return {
            title: this.share.foo,
            path: this.share.path,
            imageUrl: this.share.imageUrl,
        }
    }
}